﻿<template>
    <div id="app">
        <h-header :headertitle="title"></h-header>
        <swipe :data="swipedata"></swipe>
    

        <cell  :tabs='tabs'></cell>
        <food :data='fooddata'></food>
    </div>
</template>

<script>
    import header from '../components/header.vue';
    import swipe from '../components/swipe.vue';
    import scroll from '../components/scroll.vue';
    import cell from '../components/cell.vue';
    import food from '../components/food.vue';
    import Bus from '../bus.js'
    export default {
        name: 'app',
        data() {
            return {
                title: '首页',
                tabs: [{
                    id: 0,
                    name: '签到',
                    imgurl: require("../assets/images/sign.png")
                }, {
                    id: 1,
                    name: '视频',
                    imgurl: require("../assets/images/video.png")
                }, {
                    id: 1,
                    name: '食谱',
                    imgurl: require("../assets/images/food.png")
                }, {
                    id: 1,
                    name: '风采',
                    imgurl: require("../assets/images/news.png")
                }, {
                    id: 1,
                    name: '消息',
                    imgurl: require("../assets/images/message.png")
                }, {
                    id: 1,
                    name: '请假',
                    imgurl: require("../assets/images/leave.png")
                }, {
                    id: 1,
                    name: '作业',
                    imgurl: require("../assets/images/broadcast.png")
                }, {
                    id: 1,
                    name: '设置',
                    imgurl: require("../assets/images/set.png")
                }

                ],
                swipedata: [],
                newsdata: [],
                fooddata: [],
           
            }
        },
        components: {
            'h-header': header,
            'swipe': swipe,
            'scroll': scroll,
            'cell': cell,
            'food': food


        },
        props: {
         
        },
        mounted() {
            window.history.pushState('forward', null, '#');
            window.history.forward(1);

            window.onpopstate = () => {
              

            }
        },
        methods: {
            load: function () {
                var mid = window.localStorage.getItem("mid");
                var _this = this;
                this.$api.post('wx/Index/gethome', {
                    "mid": mid
                }, response => {
                    if (response.status >= 200 && response.status < 300) {
                        var data = response.data;
                        console.log(data);
                        if (data.status == 200) {
                            _this.$data.swipedata = data.imagelist;
                            _this.$data.newsdata = data.newslist;
                            _this.$data.fooddata = data.foodlist;

                        } else {
                            Toast(data.message);
                        }
                        //this.$data.code = response.data;

                        //请求成功，response为成功信息参数
                    } else {
                        Toast("请求失败");
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });

            }
            

        },
        created() {
           
            this.load();
            Bus.$emit('backshow', "0")

        }

    };
</script>

<style scoped>
</style>